const { Router } = require('express')
const {
  adminLogin,
  adminLogout,
  adminUpdatePassword,
  adminUpdateInfo,
  adminGetInfo,
} = require('../controllers/adminController')
const interceptor = require('../middlewares/interceptor')
const restrictTo = require('../middlewares/restrictTo')

const router = Router()

// router.post('/admin', addAdmin)  // 需要添加用户的时候启用
router.get('/admin/info', adminGetInfo)
router.post('/admin', adminLogin)
router.get('/admin', interceptor, adminLogout)
router.patch('/admin/:id', interceptor, restrictTo(['admin']), adminUpdatePassword)
router.put('/admin/:id', interceptor, restrictTo(['admin']), adminUpdateInfo)

module.exports = router
